#传入属性，自动生成init方法
def createInit():
    arr = input("")
    list=arr.split(",")
    for i in list:
        i=i.strip()
        print("self._%s=%s"%(i,i))
#传入属性，自动生成get和set方法
def createGetAndSet():
    arr = input("")
    list = arr.split(",")
    for i in list:
        i=i.strip()
        print("def get%s(self):\n\treturn self._%s"%(i.capitalize(),i))
        print("def set%s(self,%s):\n\tself._%s=%s"%(i.capitalize(),i,i,i))
#题目一
class Aircondition(object):
    def __init__(self,brand,price):
       self._brand=brand
       self._price=price
    def getBrand(self):
       return self._brand
    def setBrand(self,brand):
       self._brand = brand
    def getPrice(self):
        return self._price
    def setPrice(self, price):
       self._price = price
    def open(self):
        print("空调开机了...")
    def close(self,time):
        print("空调将在%s分钟后自动关闭..."%time)
class testAircondition(object):
    aircondition=Aircondition("格力","2999")
    print(aircondition.getBrand(),aircondition.getPrice())
    aircondition.open()
    aircondition.close(5)
#打电话业务逻辑
class Person(object):
    def __init__(self, name, gender, age, remainingPhoneChargesOwned, phoneBrand, phoneBatteryCapacity, phoneScreenSize, maximumStandbyTimeOfThePhone, pointsOwned):
        self._name=name
        self._gender=gender
        self._age=age
        self._remainingPhoneChargesOwned=remainingPhoneChargesOwned
        self._phoneBrand=phoneBrand
        self._phoneBatteryCapacity=phoneBatteryCapacity
        self._phoneScreenSize=phoneScreenSize
        self._maximumStandbyTimeOfThePhone=maximumStandbyTimeOfThePhone
        self._pointsOwned=pointsOwned

    def getName(self):
        return self._name

    def setName(self, name):
        self._name = name

    def getGender(self):
        return self._gender

    def setGender(self, gender):
        self._gender = gender

    def getAge(self):
        return self._age

    def setAge(self, age):
        self._age = age

    def getRemainingphonechargesowned(self):
        return self._remainingPhoneChargesOwned

    def setRemainingphonechargesowned(self, remainingPhoneChargesOwned):
        self._remainingPhoneChargesOwned = remainingPhoneChargesOwned

    def getPhonebrand(self):
        return self._phoneBrand

    def setPhonebrand(self, phoneBrand):
        self._phoneBrand = phoneBrand

    def getPhonebatterycapacity(self):
        return self._phoneBatteryCapacity

    def setPhonebatterycapacity(self, phoneBatteryCapacity):
        self._phoneBatteryCapacity = phoneBatteryCapacity

    def getPhonescreensize(self):
        return self._phoneScreenSize

    def setPhonescreensize(self, phoneScreenSize):
        self._phoneScreenSize = phoneScreenSize

    def getMaximumstandbytimeofthephone(self):
        return self._maximumStandbyTimeOfThePhone

    def setMaximumstandbytimeofthephone(self, maximumStandbyTimeOfThePhone):
        self._maximumStandbyTimeOfThePhone = maximumStandbyTimeOfThePhone

    def getPointsowned(self):
        return self._pointsOwned

    def setPointsowned(self, pointsOwned):
        self._pointsOwned = pointsOwned
    def sendMessage(self,message):
        print("发送%s短信成功"%message)
    def cellPhone(self,phone,time):
        if phone=="":
            print("拨打的电话为空")
        if self.getRemainingphonechargesowned()<1:
            print("花费不足，请及时充值")
        print("电话通话中")
        #总共扣的积分
        totalPointsowned=0
        # 总共扣的钱
        totalMoney = 0
        # 时间区间  积分  钱
        if time>=0 and time<=10:
            #积分够的话，先扣积分
            #积分完全够的话，都扣积分,直接返回
            if self.getPointsowned()/15>=time:
                totalPointsowned+=time*15  #扣积分
                return totalPointsowned,totalMoney
            else:
                #积分不够，先扣部分积分
                totalPointsowned += (self.getPointsowned()/15)*15#扣积分
                time=time-self.getPointsowned()/15
                #接下来，用钱扣
                #钱够的话,扣钱,返回
                if self.getRemainingphonechargesowned()>=time*1:
                    totalMoney+=time#扣钱
                    return totalPointsowned, totalMoney
                #钱不够，将钱扣完
                else:
                    totalMoney+=self.getRemainingphonechargesowned()
                    return totalPointsowned, totalMoney
        elif time>=10 and time<=20:
            backPointsowned=self.getPointsowned()#备用积分余额，用于计算
            backRemainingphonechargesowned=self.getRemainingphonechargesowned()#备用钱余额，用于计算
            #可以先扣掉10以下的花费，再进行计算
            #如果10分钟以下，积分支付的起
            if self.getPointsowned()/15>=10:
                totalPointsowned+=150#扣积分
                time = time - 10#扣时间
                backPointsowned -= 150
            # 如果10分钟以下，积分支付不起
            else:
                totalPointsowned += (self.getPointsowned()/15)*15#扣积分
                time=time-self.getPointsowned()/15#扣时间
                #用钱支付
                #钱也支付不起
                if  self.getRemainingphonechargesowned()<(10-(self.getPointsowned()/15)):
                    totalMoney+=self.getRemainingphonechargesowned()
                    return totalPointsowned, totalMoney
                #用钱支付的起
                else:
                    totalMoney+=10-self.getPointsowned()/15
                    time = time - (10-self.getPointsowned()/15)
                    backPointsowned-=(self.getPointsowned()/15)*15
                    backRemainingphonechargesowned-=10-(self.getPointsowned()/15)
            #剩下使用10到20的支付标准
            # 积分够的话，先扣积分
            # 积分完全够的话，都扣积分,直接返回
            if backPointsowned / 39 >= time:
                totalPointsowned += time * 39  # 扣积分
                return totalPointsowned, totalMoney
            else:
                #积分不够，先扣部分积分
                totalPointsowned += (backPointsowned / 39) * 39  # 扣积分
                time = time - backPointsowned / 39
                # 接下来，用钱扣
                # 钱够的话,扣钱,返回
                if backRemainingphonechargesowned >= time * 0.8:
                    totalMoney += time*0.8  # 扣钱
                    return totalPointsowned, totalMoney
                # 钱不够，将钱扣完,返回
                else:
                    totalMoney += backRemainingphonechargesowned
                    return totalPointsowned, totalMoney
        else:
            # print(1)
            backPointsowned = self.getPointsowned()  # 备用积分余额，用于计算
            backRemainingphonechargesowned = self.getRemainingphonechargesowned()  # 备用钱余额，用于计算
            # 可以先扣掉10以下的花费，再进行计算
            # 如果10分钟以下，积分支付的起
            if self.getPointsowned() / 15 >= 10:
                totalPointsowned += 150  # 扣积分
                time = time - 10  # 扣时间
                backPointsowned -= 150
            # 如果10分钟以下，积分支付不起
            else:
                totalPointsowned += (self.getPointsowned() / 15) * 15  # 扣积分
                time = time - self.getPointsowned() / 15  # 扣时间
                # 用钱支付
                # 钱也支付不起
                if self.getRemainingphonechargesowned() < (10 - (self.getPointsowned() / 15)):
                    totalMoney += self.getRemainingphonechargesowned()
                    return totalPointsowned, totalMoney
                # 用钱支付的起
                else:
                    totalMoney += 10 - self.getPointsowned() / 15
                    time = time - (10 - self.getPointsowned() / 15)
                    backPointsowned -= (self.getPointsowned() / 15) * 15
                    backRemainingphonechargesowned -= 10 - (self.getPointsowned() / 15)
            # 剩下使用10到20的支付标准
            # 积分够的话，先扣积分
            # 积分完全够的话，都扣积分,直接返回
            if backPointsowned / 39 >= 10:
                totalPointsowned += 390  # 扣积分
                time = time - 10  # 扣时间
                backPointsowned -= 390
            else:
                # 积分不够，先扣部分积分
                totalPointsowned += (backPointsowned / 39) * 39  # 扣积分
                time = time - backPointsowned / 39
                # 接下来，用钱扣
                # 钱够的话,扣钱,返回
                if backRemainingphonechargesowned >= time * 0.8:
                    totalMoney += time * 0.8  # 扣钱
                    time = time - (10 - backRemainingphonechargesowned / 39)
                    backPointsowned -= (self.getPointsowned() / 39) * 39
                    backRemainingphonechargesowned -= (10 - (self.getPointsowned() / 39))*0.8
                # 钱不够，将钱扣完,返回
                else:
                    totalMoney += backRemainingphonechargesowned
                    return totalPointsowned, totalMoney

        #剩下使用20以上的支付标准
        # 积分够的话，先扣积分
        # 积分完全够的话，都扣积分,直接返回
        if backPointsowned / 48 >= time:
            totalPointsowned += time * 48  # 扣积分
            return totalPointsowned, totalMoney
        else:
            #积分不够，先扣部分积分
            totalPointsowned += (backPointsowned / 48) * 48  # 扣积分
            time = time - backPointsowned / 48
            # 接下来，用钱扣
            # 钱够的话,扣钱,返回
            if backRemainingphonechargesowned >= time * 0.65:
                totalMoney += time*0.65  # 扣钱
                return totalPointsowned, totalMoney
            # 钱不够，将钱扣完,返回
            else:
                totalMoney += backRemainingphonechargesowned
                return totalPointsowned, totalMoney
class testPerson(object):
    person=Person("杜志远","男",22,100,"华为",100,700,24,200)
    person.sendMessage("你好")
    totalPointsowned, totalMoney=person.cellPhone("123456",10)
    print("花费积分%s,花费余额%s"%(totalPointsowned, totalMoney))
#题目四：需求编程
class Student(object):
    def __init__(self,StudentID, name, age, gender, height, weight, grades, homeAddress, phoneNumber):
        self._StudentID = StudentID
        self._name = name
        self._age = age
        self._gender = gender
        self._height = height
        self._weight = weight
        self._grades = grades
        self._homeAddress = homeAddress
        self._phoneNumber = phoneNumber
    def study(self,studyTime):
        print("学习:%s分钟"%(studyTime))
    def playGame(self,playGameName):
        print("正在玩%s"%(playGameName))
    def Program(self,ProgramRow):
        print("写%s行代码"%ProgramRow)
    def sumList(self,list,start,end):
        total=0
        for i in range(start,end):
            total+=list[i]
        return total
class testStudent(object):
    student=Student("123456789","张三",20,"男",175,65,"大一","北京市朝阳区某某街道123号","13800138000")
    student.study(1)
    student.playGame("王者荣耀")
    student.Program(500)
    list=[1,2,3,4,5,6]
    student.sumList(list,5,6)
class Car(object):
    def __init__(self,Attributes, modelNumber, numberOfWheels, bodyColor, vehicleWeight, fuelTank,storageSize):
        self._Attributes = Attributes
        self._modelNumber = modelNumber
        self._numberOfWheels = numberOfWheels
        self._bodyColor = bodyColor
        self._vehicleWeight = vehicleWeight
        self._fuelTank = fuelTank
        self._storageSize = storageSize
class testCar(object):
    car1 = Car("崭新出厂","法拉利","S",4,"红色","30kg",600)
    car2 = Car("崭新出厂","宝马","S",4,"红色","35kg",600)
    car3 = Car("崭新出厂","铃木","A",2,"红色","20kg",600)
    car4 = Car("崭新出厂","五菱","C",4,"红色","25kg",600)
    car5 = Car("崭新出厂","拖拉机","D",4,"红色","45kg",600)
class NoteWork(object):
    def __init__(self,model, standbyTime, color, weight, CPUModel, memorySize, hardDiskSize):
        self._model = model
        self._standbyTime = standbyTime
        self._color = color
        self._weight = weight
        self._CPUModel = CPUModel
        self._memorySize = memorySize
        self._hardDiskSize = hardDiskSize
    def playGame(self,gameName):
        print("正在玩%s"%gameName)
    def work(self):
        print("正在工作")
class testNoteWork(object):
    noteWork = NoteWork("z790",24,"红色","15kg","i9",64,512)
    noteWork.playGame("csgo")
    noteWork.work()
class Monkey(object):
    def __init__(self,Category, gender, bodyColor, weight):
        self._Category = Category
        self._gender = gender
        self._bodyColor = bodyColor
        self._weight = weight
    def useFire(self,material):
        print("使用%s来造火"%material)
    def study(self,obj):
        print("正在学习%s"%obj)
class testMonkey(object):
    monkey = Monkey("猿人","男","黄色","65kg")
    monkey.useFire("木头")
    monkey.study("站岗")
if __name__ == '__main__':
   createGetAndSet()